package com.explam.springboot.exception;
import com.explam.springboot.common.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public ResultUtil handle(ServiceException e){
        return ResultUtil.error(e.getCode(),e.getMessage());
    }
}
